<template>
	<view class="p-l-30 p-r-30">
		<view class="" v-if="select==1">
			<view class="bg-white br20 p-30 m-t-20"  >
				
				<view class="goods-desc p-20 br10"  >
					<u-input type="textarea" v-model="desc" 
					:clearable="false"
					placeholder="填写订单备注,给司机捎句话~" 
					maxlength="80"></u-input>
				</view>
				<view class="flex row-between">
					<view style="color: #BBBBBB ;">
						{{desc.length}}/80
					</view>
					<view style="color: #BBBBBB;" @click="desc=''">
						清空
					</view>
				</view>
			</view>
			<!-- <view class="bg-white br20 p-30 m-t-20"  >
				<view class="bold p-b-40 xl">
					支付小费
				</view>
				<view class="goods-desc p-20 br10"  >
					<u-input type="number" v-model="desc" placeholder="输入要支付的小费" maxlength="10"></u-input>
				</view>
			</view> -->
		</view>
		
		<view class="m-t-20" v-if="select==2" >
			<view class="">
				<view class="bold xxl">
					搬运服务
				</view>
				<view class="tip-content">
					装卸服务，无需求可不选。
				</view>
				<view class="m-t-20">
					<u-cell-group>
						<u-cell-item  title="查看平台计价参考" @click='openvaluation' ></u-cell-item>
						<u-cell-item  title="是否需要搬运" :value="carryValue" @click='carryShow=true' ></u-cell-item>
						<u-cell-item  title="是否装有电梯" :value="elevatorValue" @click='elevatorShow=true' v-if="is_carry==1" ></u-cell-item>
						<u-cell-item  title="需要搬运层数" v-if="is_elevator==0" :arrow="false">
							<view class="" slot="right-icon">
								<u-input v-model="floor_num" placeholder="请输入楼层数" type='number' input-align="right"></u-input>
							</view>
						</u-cell-item>
					</u-cell-group>
				</view>
			</view>
			<view class="m-t-20">
				<view class="bold">
					其他服务
				</view>
				<view class="m-t-20">
					<view class="br20" style="overflow: hidden;">
						
				
					<view class="bg-white p-20 ">
						<view class="flex row-between">
							<view>
								返程
							</view>
							<view>
								<u-checkbox-group>
									<u-checkbox v-model="is_back" active-color="#f16625" shape="circle"></u-checkbox>
								</u-checkbox-group>
							</view>
						</view>
					</view>
			
					</view>
				</view>
			</view>
		</view>
		<view class="desc-btn" @click="editUserDesc">
			确定
		</view>
		<u-select :list="carryList" v-model="carryShow" @confirm="carrySure($event,1)"></u-select>
		<u-select :list="elevatorList" v-model="elevatorShow" @confirm="carrySure($event,2)"></u-select>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				select:1,
				desc:'',
				carryValue:'不需要搬运',
				is_carry:0,
				carryShow:false,
				carryList:[
					{
						label:'不需要搬运',
						value:0
					},
					{
						label:'需要搬运',
						value:1
					},
				],
				elevatorValue:'有电梯',
				elevatorShow:false,
				is_elevator:1,
				elevatorList:[
					{
						label:'有电梯',
						value:1
					},
					{
						label:'无电梯',
						value:0
					},
				],
				floor_num:1,
				is_back:false,
				car_id:""
			}
		},
		onLoad(option) {
			let {select} = option;
			if(select==1){
				this.select = select;
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - 2]; // 上一页
				this.desc = beforePage.$vm.user_remarks
				uni.setNavigationBarTitle({
					title: '用户备注'
				});
			}
			if(select==2){
				 this.car_id=option.carid
				this.select = select;
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - 2]; // 上一页
				
				this.is_carry = beforePage.$vm.is_carry ;
				this.is_elevator = beforePage.$vm.is_elevator ;
				this.floor_num =  beforePage.$vm.floor_num ;
				this.is_back  = Boolean( beforePage.$vm.is_back);
				if(this.is_carry==0){
					this.carryValue = '不需要搬运'
				}
				if(this.is_elevator==0){
					this.elevatorValue = '无电梯'
				}
				uni.setNavigationBarTitle({
					title: '搬运及其他服务'
				})
			}
		},
		methods: {
			//打开计价页面
			openvaluation(){
				uni.navigateTo({
					url:"bundle/pages/reference/reference?id="+ this.car_id
				})
			},
			carrySure(e,index){
				if(index==1){
					this.carryValue = e[0].label;
					this.is_carry =  e[0].value;
				}
				if(index==2){
					this.elevatorValue = e[0].label;
					this.is_elevator =  e[0].value;
				}
				
			},
			//确定修改的的服务
			editUserDesc(){
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - 2]; // 上一页
				if(this.select==1){
					if(!!this.desc){
						beforePage.$vm.user_remarks = this.desc;
						beforePage.$vm.descValue = this.desc;
					}
				}
				if(this.select==2){
					beforePage.$vm.is_carry = this.is_carry;
					beforePage.$vm.is_elevator = this.is_elevator;
					beforePage.$vm.floor_num = this.floor_num;
					let mes = this.carryValue;
					if(this.is_carry==1){
						 mes = this.carryValue + ' | '+ this.elevatorValue;
						console.log(mes)
						if(this.is_elevator==0){
							 mes = this.carryValue + ' | '+ this.elevatorValue + ' | ' + this.floor_num + '楼'
						}
					}
					beforePage.$vm.carryValue = mes
					beforePage.$vm.is_back = Number(this.is_back);
					beforePage.$vm.isChange = true;
					// beforePage.$vm.user_remarks = this.desc;
					// beforePage.$vm.is = this.desc;
				}
				uni.navigateBack({
					
				})
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.tip-content{
		margin-top:8rpx;
		color: #979696;
	}
	.goods-desc{
		border-radius: 10rpx;
		overflow: hidden;
		background-color: #FFFFFF;
	}
	.desc-btn{
		margin-top: 40rpx;
		box-shadow: 0upx 10upx 10upx 0upx #f7d4cd;
		background: linear-gradient(#e36e51  , #df563b);
		color: #fff;
		padding: 30rpx 0;
		text-align: center;
		border-radius: 10rpx;
	}
</style>
